package main;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;

import com.swf.common.filter.FwsNameFilter;
import com.swf.common.operator.IFwsFileOperator;
import com.swf.common.utils.FwsFileUtils;
import com.swf.common.utils.FwsPatternUtils;

public class getEcsOrder {
	public static Map<String, String> map = new TreeMap<String, String>();
	public static void main(String[] args) {
		File file = FwsFileUtils.getFile("D:/yeb/dev/dev0312/partner-api/trunk/partner-dao/src/main/java/com/hundsun/fund/partner/dao");
		FwsFileUtils.goThrough(file, new FwsNameFilter(){
			@Override
			public boolean include(String name) {
				return name.endsWith("java");
			}
		}, new IFwsFileOperator() {
			
			@Override
			public void execute(File file) {
				String content;
				try {
					content = FwsFileUtils.loadFile(file, "UTF-8");
					List<String> list = FwsPatternUtils.matchedList(content, "name.+column.+\"");
					List<String> list1 = FwsPatternUtils.matchedList(content, "name.+field.+\"");
					for (String s:list){
						String name = FwsPatternUtils.matchedFirstOne(s, 1, "\"(.+)\".+\"(.+)\"");
						String value = FwsPatternUtils.matchedFirstOne(s, 2, "\"(.+)\".+\"(.+)\"");
						//System.out.println(name+":"+value);
						map.put(name, value);
					}
					for (String s:list1){
						String name = FwsPatternUtils.matchedFirstOne(s, 1, "\"(.+)\".+\"(.+)\"");
						String value = FwsPatternUtils.matchedFirstOne(s, 2, "\"(.+)\".+\"(.+)\"");
						//System.out.println(name+":"+value);
						map.put(value, name);
					}
				} catch (FileNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		});
		//System.out.println(map);
		for (Entry<String, String> entry: map.entrySet()) {

		    String key = entry.getKey();

		    String value = entry.getValue();
		    System.out.println(
		    		"INSERT INTO tecsorder(vc_standardname,vc_orderno) VALUES ('"+key+"','"+value+"');");
		}
	}
	
}
